'use strict'
const path = require('path')

function resolve(dir) {
  return path.join(__dirname, dir)
}

const name = 'defc-vue-template' // page title

const port = process.env.port || process.env.npm_config_port || 9527 // dev port

module.exports = {

  publicPath: '/',
  outputDir: 'dist',
  assetsDir: 'static',
  // lintOnSave: process.env.NODE_ENV === 'development',
  lintOnSave: false,
  productionSourceMap: false,
  devServer: {
    port: port,
    open: true,
    overlay: {
      warnings: false,
      errors: true
    }
  },
  configureWebpack: {
    name: name,
    resolve: {
      alias: {
        '@': resolve('src'),
        leaflet_css: __dirname + "/node_modules/leaflet/dist/leaflet.css",
        leaflet_marker: __dirname + "/node_modules/leaflet/dist/images/marker-icon.png",
        leaflet_marker_2x: __dirname + "/node_modules/leaflet/dist/images/marker-icon-2x.png",
        leaflet_marker_shadow: __dirname + "/node_modules/leaflet/dist/images/marker-shadow.png",
      }
    }
  },
  chainWebpack(config) {
    config.plugin('preload').tap(() => [
      {
        rel: 'preload',
        fileBlacklist: [/\.map$/, /hot-update\.js$/, /runtime\..*\.js$/],
        include: 'initial'
      }
    ])
    config.plugins.delete('prefetch')
  },
  css: {
    // css预设器配置项
    loaderOptions: {
      sass: {
        prependData:`@import "./src/styles/variables.scss";`//全局的scss变量
      }
    }
  },
}
